package com.jweb.framework.ws.soap.axiom;

import org.apache.axiom.om.OMException;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFault;
import org.apache.axiom.soap.SOAPFaultDetail;
import org.apache.axiom.soap.SOAPFaultRole;
import org.apache.axiom.soap.SOAPProcessingException;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.SoapFaultDetail;
/**
 * 修改人： Thomas
 * 修改内容：新增 
 * 类说明：
 */
abstract class AxiomSoapFault extends AxiomSoapElement implements SoapFault {
	
	protected AxiomSoapFault(SOAPFault axiomFault , SOAPFactory axiomFactory) {
		super(axiomFault, axiomFactory);
	}
	
	public String getFaultActorOrRole(){
		SOAPFaultRole faultRole = getAxiomFault().getRole();
		return faultRole != null ? faultRole.getRoleValue() : null ;
	}
	
	public void setFaultActorOrRole(String actor){
		try {
			SOAPFaultRole axiomFaultRole = getAxiomFactory().createSOAPFaultRole(getAxiomFault());
			axiomFaultRole.setRoleValue(actor);
		} catch (SOAPProcessingException e) {
			throw new AxiomSoapFaultException(e);
		}
	}
	
	
	public SoapFaultDetail getFaultDetail(){
		try {
			SOAPFaultDetail axiomFaultDetail = getAxiomFault().getDetail();
			return axiomFaultDetail != null ? new AxiomSoapFaultDetail(axiomFaultDetail , getAxiomFactory()) : null ;
		} catch (OMException e) {
			throw new AxiomSoapFaultException(e);
		}
	}
	
	public SoapFaultDetail addFaultDetail(){
		try {
			SOAPFaultDetail axiomFaultDetail = getAxiomFactory().createSOAPFaultDetail(getAxiomFault());
			return new AxiomSoapFaultDetail(axiomFaultDetail , getAxiomFactory());
		} catch (OMException e) {
			throw new AxiomSoapFaultException(e);
		}
	}
	
	
	protected SOAPFault getAxiomFault(){
		return (SOAPFault) getAxiomElement();
	}

}
